/**
 * Created by 周颖 on 2017/7/26.
 *
 * axios post请求默认提交的是JSON,如果需要提交 application/x-www-form-urlencoded =>
 * 1、引入 import queryString from 'querystring';
 * 2、参数 queryString.stringify(para)
 * [参考](https://github.com/mzabriskie/axios#using-applicationx-www-form-urlencoded-format)
 *
 *
 * [接口地址](http://59.107.26.181:8086/swagger-ui.html)
 */


import axios from 'axios';

let api = {
  getActivityList: '/api-active/v1/api/activityCenter/activity/',           // 活动列表=> activityCenter/ActivityCouponsLook
  getActivityType: '/api-active/v1/api/OptionDetails/activity/type',        //获取所有活动类型
  createActivity: '/api-active/v1/api/activityCenter/activity',             //创建活动
  couponList: '/api-active/v1/api/coupon/api/coupon/list?status=ENABLE',    //编辑活动
  activityParm: '/api-active/v1/api/activityCenter/activity/param',         //活动特殊参数
  activityDetail: '/api-active/v1/api/activityCenter/activity',
  getActParam: '/api-active/v1/api/activityCenter/activity/',               // 查询活动配置信息
  disableCoupon: '/api-active/v1/api/activityCenter/activity/disableCoupon' //禁止卡券
}

const getActivityList = (actId) => {
  return axios.get(api.getActivityList + actId)
}

const getActParam = (actId) => {
  return axios.get(api.getActParam + actId + '/param')
}

const getActivityType = () => {
  return axios.get(api.getActivityType)
}

const createActivity = (parma) => {
  return axios.post(api.createActivity, parma)
}

const editActivity = (parm) => {
  return axios.put(api.createActivity, parm)
}

const couponList = () => {
  return axios.get(api.couponList)
}

const activityParm = (parm) => {
  return axios.put(api.activityParm, parm)
}

const activityDetail = (id) => {
  return axios.get(api.activityDetail + '/' + id)
}

const disableCoupon = (parm) => {
  return axios.put(api.disableCoupon + '?activityId=' + parm.activityId + '&activityCouponId=' + parm.activityCouponId)
}

export {
    api,
    getActivityList,
    getActivityType,
    createActivity,
    couponList,
    getActParam,
    activityParm,
    editActivity,
    activityDetail,
    disableCoupon
}
